package org.example;

import javax.swing.*;
import java.awt.*;

public class Frame2 extends JFrame {
    private Container contentP; //内容面板
    private JButton yes;
    private JButton no;
    private JTextField name;
    private JTextField age;
    private JTextField gender;
    private JTextField address;
    private JTextArea msgArea;
    private JRadioButton maleRad; //男性单选框
    private JRadioButton femaleRad; //女性单选框

    private JLabel order;

    private JLabel name1;

    private JLabel age1;

    private JLabel address1;

    private JLabel gender1;

    public Frame2() {
        this.setSize(500, 500);
        this.setLocationRelativeTo(null);
        this.setTitle("学员信息统计表");
        this.setIconImage(Toolkit.getDefaultToolkit().createImage("img/pexels-artem-beliaikin-853199.jpg"));
        this.setResizable(true);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        this.addContent2();

        this.setVisible(true);
    }

    private void addContent2() {
        this.contentP = this.getContentPane();//获取窗体的内容面板
        this.contentP.setLayout(null);//设置空布局，即采用绝对定位的方式
        this.contentP.setBackground(Color.gray);//设置内容面板背景色


        this.address = new JTextField();
        this.no = new JButton();
        this.yes = new JButton();
        this.gender = new JTextField();
        this.msgArea = new JTextArea();
        this.order = new JLabel();
        this.femaleRad = new JRadioButton();
        this.maleRad = new JRadioButton();
        this.name = new JTextField();
        this.age = new JTextField();
        this.name1 = new JLabel();
        this.age1 = new JLabel();
        this.gender1 = new JLabel();
        this.address1 = new JLabel();

        this.order.setText("学员信息统计表");
        this.order.setFont(new Font("宋体", Font.ITALIC, 32));
        this.order.setBounds(100, 20, 400, 100);

        this.name1.setText("姓名");
        this.age1.setText("年龄");

        this.gender1.setText("性别");

        this.name1.setBounds(50, 100, 40, 40);
        this.age1.setBounds(50, 130, 40, 40);
        this.gender1.setBounds(50, 160, 40, 40);

        this.name.setBounds(100, 100, 100, 40);
        this.age.setBounds(100, 130, 100, 40);
        this.gender.setBounds(100, 160, 100, 40);

        this.address1.setText("地址");
        this.address1.setBounds(50, 190, 40, 40);
        this.address.setBounds(100, 190, 200, 40);

        this.femaleRad.setText("男");
        this.femaleRad.setBounds(300, 160, 50, 50);
        this.maleRad.setText("女");
        this.maleRad.setBounds(350, 160, 50, 50);

        this.msgArea.setBounds(50, 250, 400, 150);

        this.yes.setText("确定");
        this.no.setText("返回");

        this.yes.setBounds(240, 400, 40, 40);
        this.no.setBounds(280, 400, 40, 40);


        this.contentP.add(this.name1);
        this.contentP.add(this.name);
        this.contentP.add(this.age);
        this.contentP.add(this.age1);
        this.contentP.add(this.address);
        this.contentP.add(this.address1);
        this.contentP.add(this.gender1);
        this.contentP.add(this.gender);
        this.contentP.add(this.order);
        this.contentP.add(this.maleRad);
        this.contentP.add(this.femaleRad);
        this.contentP.add(this.order);
        this.contentP.add(this.msgArea);
        this.contentP.add(this.yes);
        this.contentP.add(this.no);
    }
}
